<!-- comment.html -->
{% extends 'base.html' %}

{% block left %}
    <h1>评论 - {{ article.title }}</h1>
    <div>{{article.body_html | safe}}</div>
        <form method="post" action="{% url 'comment' article.id %}">
            {% csrf_token %}
            <label for="name">姓名:</label><br>
            <input type="text" id="name" name="name" required><br>
            <label for="email">邮箱:</label><br>
            <input type="email" id="email" name="email" required><br>
            <label for="content">评论内容:</label><br>
            <textarea id="content" name="content" rows="4" cols="50" required></textarea><br>
            <button type="submit">提交评论</button>
        </form>

        {% if messages %}
            {% for message in messages %}
                <div class="alert alert-{{ message.tags }}">
                    {{ message }}
                </div>
            {% endfor %}
        {% endif %}

    <h3>已有评论</h3>
    {% for comment in comments %}
        <div class="comment">
            <p><strong>{{ comment.name }} ({{ comment.email }})</strong></p>
            <p>{{ comment.content }}</p>
            <p>发表于：{{ comment.created_at }}</p>
        </div>
    {% empty %}
        <p>暂无评论。</p>
    {% endfor %}
{% endblock %}